package com.caregiver.watch.business.care.model.vo;

import com.caregiver.watch.common.utils.time.DateUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;

/**
 * @description: 血氧详情数据
 * @program: caregiver-watch
 * @author: 疆戟
 * @create: 2025-10-07 11:32
 */
@Data
@Schema(description = "血氧详情数据")
public class BloodOxygenDetailDataVo {

    @Schema(description = "平均血氧(当天平均值)")
    private BigDecimal averageBloodOxygen;

    @Schema(description = "最低血氧(当天最低)")
    private BigDecimal lowestBloodOxygen;

    @Schema(description = "最高血氧(当天最高)")
    private BigDecimal highestBloodOxygen;

    @Schema(description = "当天血氧数据列表")
    private List<BloodOxygenData> bloodOxygenDataList;

    public static BloodOxygenDetailDataVo build(BigDecimal averageBloodOxygen,
                                                BigDecimal lowestBloodOxygen,
                                                BigDecimal highestBloodOxygen,
                                                List<BloodOxygenData> bloodOxygenDataList) {
        BloodOxygenDetailDataVo bloodOxygenDetailDataVo = new BloodOxygenDetailDataVo();
        bloodOxygenDetailDataVo.averageBloodOxygen = averageBloodOxygen;
        bloodOxygenDetailDataVo.lowestBloodOxygen = lowestBloodOxygen;
        bloodOxygenDetailDataVo.highestBloodOxygen = highestBloodOxygen;
        bloodOxygenDetailDataVo.bloodOxygenDataList = bloodOxygenDataList;
        return bloodOxygenDetailDataVo;
    }

    @Data
    @Schema(description = "当天血氧数据")
    public static class BloodOxygenData {

        @Schema(description = "时间（分钟）")
        private Integer time;
        @Schema(description = "平均血氧")
        private BigDecimal averageBloodOxygen;

        public static BloodOxygenData build(LocalDateTime time, BigDecimal averageBloodOxygen) {
            BloodOxygenData bloodOxygenData = new BloodOxygenData();
            bloodOxygenData.time = DateUtils.getMinute(time);
            bloodOxygenData.averageBloodOxygen = averageBloodOxygen;
            return bloodOxygenData;
        }
    }
}
